<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateActivitiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activities', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('brandId')->comment('品牌id')->default(0);
            $table->unsignedTinyInteger('status')->comment('活动状态')->default(0);
            $table->unsignedTinyInteger('shopType')->comment('店铺类型 0-全部，1-加盟，2-直营，3-部分选择')->default(0);
            $table->string('name', 50)->comment('活动名称')->default('');
            $table->unsignedTinyInteger('type')->comment('活动类型')->default(0);
            $table->unsignedInteger('startAt')->default(0)->comment('有限时间活动，开始时间，闭区间，0时为长期活动');
            $table->unsignedInteger('endAt')->default(4294967295)->comment('有限时间活动，结束时间，闭区间');
            $table->unsignedInteger('isSmsNotify')->default(0)->comment('短信提醒开关');
            $table->unsignedInteger('isWechatNotify')->default(0)->comment('微信提醒开关');
            $table->unsignedInteger('notifyAheadDays')->default(0)->comment('提前几天发送提醒');
            $table->string('description', 200)->default('')->comment('活动说明');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
            $table->index("isDeleted", "idx_is_deleted");
            $table->index("brandId", "brandId");
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '活动表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activities');
    }
}
